<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
				<html>
				<head>
				</head>
				<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
				<title>Images with a final diagnosis</title>
	
				
				<body>
<?php
include "config.php";

if(isset($_POST['Submit']))
{ 
$current_image=$_FILES['image']['name'];
$extension = substr(strrchr($current_image, '.'), 1);
$tmpPath = $_FILES['image']['tmp_name'];

if((mime_content_type($tmpPath) != "image/jpeg") && (mime_content_type($tmpPath) !="image/png") && (mime_content_type($tmpPath) !="image/svg+xml"))
{
die("Wrong file type. Please try again");
}

//$new_image = $current_image . "." . $extension;
$destination="imageData/".$current_image;
$action = copy($_FILES['image']['tmp_name'], $destination);
$sql="INSERT INTO images (file_path, counter)
VALUES ('$destination', 0)";
$result=mysql_query($sql);

if (!$action) 
{
die('File copy failed');
}else{
echo "File copy successful";
}
}
else{
?>
<form method="post" enctype="multipart/form-data" action="image_uploader.php">
Choose a file to upload:<input type="file" name="image" ><br>
<input type="submit" name="Submit" value="submit">
</form>
<?php
}
?>
<br/>
<a href="http://mathcs.jcu.edu/cs470clevclinic/radiollaboration/welcome.php">Home</a>

</body>
</html>
